package mydessertstore.web.servlet;

import com.alibaba.fastjson.JSON;
import mydessertstore.domain.Account;
import mydessertstore.domain.Product;
import mydessertstore.service.AccountService;
import mydessertstore.service.CatalogService;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;

public class IsUsernameExistServlet extends HttpServlet {
    AccountService service = new AccountService();

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String username = req.getParameter("username");
        //调用service dao查询username是否可用

        Account newAccount = service.getAccount(username);
        resp.setContentType("text/xml");
        PrintWriter out = resp.getWriter();

        if(newAccount != null){
            out.println("<msg>Exist</msg>");
        }else{
            out.println("<msg>NotExist</msg>");
        }


    }
}
